
local M =  _G.CommonOHOH.class.new(script,  _G.CommonOHOH.files.GameObject());

--Value 填充
function M.InitUiInst(self,uiObj,pathStr)
	if type(pathStr) ~= "table" then
		if type(pathStr) == "string" then
			return _G.CommonOHOH:GetPath_Loop(pathStr,uiObj).Value
		else
			return;
		end;
	end;
	local v2 = {};
	for v3, v4 in pairs(pathStr) do
		v2[v3] = self:InitUiInst(uiObj, v4);
	end;
	return v2;
end


function M.new(...)
	return M(...);
end;

local UIStr={
    pos="ctrl.pos",
    vipColor="ctrl.VipColor",
    level="ctrl.level",
    title="ctrl.title",
}

function M.ctor(self,character)
    local uiInst=_G.CommonOHOH:GetPath_Loop("TopUi",game.ReplicatedStorage.Resource.UI):Clone()
    M.super.ctor(self,uiInst)
    self.ui=self:InitUiInst(self.main_inst,UIStr)

    local att=Instance.new("Attachment",character:WaitForChild("Head"))
    att.CFrame=self.ui.pos

    self.main_inst.Parent=att

    self.ui.vipColor.Enabled=false
end;

function M.dtor(self)
	M.super.dtor(self);
end;

function M.GetVipTag(self)

    if self.ui.vipColor.Enabled then
        return _G.LanguageHelper:GetText(888060).." "
    end
    return ""
end 

function M.SetVip(self,isVip)
    self.ui.vipColor.Enabled=isVip
    if isVip then
        self.ui.level.Text=self:GetVipTag()..self.ui.level.Text
    end
end

function M.SetTitle(self,title)
    self.ui.title.Text=_G.LanguageHelper:GetText(title)
end

function M.SetLevel(self,Level)
    self.ui.level.Text=self:GetVipTag().._G.LanguageHelper:GetText2(888061,{Level})
end

return M